package com.ruoyi.service.impl;

import com.ruoyi.mapper.VerReviewImageMapper;
import com.ruoyi.mapper.VerReviewMapper;
import com.ruoyi.order.domain.VerReview;
import com.ruoyi.order.domain.VerReviewImage;
import com.ruoyi.service.VerReviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VerReviewServiceImpl implements VerReviewService {
    @Autowired
    private VerReviewMapper verReviewMapper;

    @Autowired
    private VerReviewImageMapper verReviewImageMapper;

    @Override
    public VerReview selectVerReviewById(Long id) {
        // 查询评论基本信息
        VerReview review = verReviewMapper.selectVerReviewById(id);

        if (review == null) {
            return null;
        }
        // 查询关联的图片
        List<VerReviewImage> images = verReviewImageMapper.selectImagesByReviewId(id);
        review.setImages(images);

        return review;
    }

    @Override
    public List<VerReview> selectVerReviewList(VerReview verReview) {
        return verReviewMapper.selectVerReviewList(verReview);
    }

    @Override
    public int deleteVerReviewByIds(Long[] ids) {
        return verReviewMapper.deleteVerReviewByIds(ids);
    }
}
